package com.tza.web.t_net.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.WindowResizeListener;
import com.google.gwt.user.client.ui.DockPanel;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.web.bindery.event.shared.EventBus;
import com.google.web.bindery.event.shared.SimpleEventBus;
import com.smartgwt.client.widgets.layout.HLayout;
import com.tza.web.t_net.client.sceens.client.component.Shortcuts;
import com.tza.web.t_net.client.sceens.client.component.TopPanel;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class tnet extends HLayout implements EntryPoint, WindowResizeListener
{

   /**
    * The message displayed to the user when the server cannot be reached or
    * returns an error.
    */
   private static final String SERVER_ERROR = "An error occurred while " + "attempting to contact the server. Please check your network " + "connection and try again.";

   /**
    * Create a remote service proxy to talk to the server-side Greeting service.
    */
   private static tnet         singleton;

   /**
    * Instantiate an application-level image bundle. This object will provide
    * programmatic access to all the images needed by widgets.
    */
   private static final Images images       = GWT.create(Images.class);

   /**
    * An aggragate image bundle that pulls together all the images for this
    * application into a single bundle.
    */
   public interface Images extends Shortcuts.Images, TopPanel.Images
   {
   }

   /**
    * Gets the singleton Mail instance.
    */
   public static tnet get()
   {
      return singleton;
   }

   public static EventBus EVENT_BUS = GWT.create(SimpleEventBus.class);
   private TopPanel       topPanel  = new TopPanel(images);
   private Shortcuts      shortcuts = new Shortcuts(images);

   public void onModuleLoad()
   {

      singleton = this;

      topPanel.setWidth("100%");

      DockPanel outer = new DockPanel();
      outer.add(topPanel, DockPanel.NORTH);
      outer.add(shortcuts, DockPanel.WEST);
      outer.setWidth("100%");

      outer.setSpacing(4);

      // Hook the window resize event, so that we can adjust the UI.
      Window.addWindowResizeListener(this);

      // Get rid of scrollbars, and clear out the window's built-in margin,
      // because we want to take advantage of the entire client area.
      Window.enableScrolling(false);
      Window.setMargin("0px");

      // Finally, add the outer panel to the RootPanel, so that it will be
      // displayed.
      RootPanel.get().add(outer);

   }

   public void onWindowResized(int width, int height)
   {
      // TODO Auto-generated method stub

   }

}
